from ..items import IfengItem
from scrapy.spiders import XMLFeedSpider

class IfengSpider(XMLFeedSpider):
	name = 'ifeng'
	# allowed_domains = ['ifeng.com']
	start_urls = ['https://house.ifeng.com/rss/hengda/index']
	iterator = 'xml'  # you can change this; see the docs
	itertag = 'item'  # change it accordingly
	
	def parse_node(self, response, selector):
		items = selector.css('item')
		item_field = {}
		for item in items:
			item_field['title'] = item.css('title::text').get('')
			item_field['link'] = item.css('link::text').get('')
			item_field['content'] = item.css('description::text').get('')
			item_field['source'] = item.css('source::text').get('')
			item_field['author'] = item.css('source::text').get('')
			item_field['pub_time'] = item.css('pubDate::text').get('')
			yield item_field
		print(item_field)
